03 / 06

How can you apply inline styles in HTML?

Applying Inline Styles in HTML

Inline styles in HTML allow you to apply CSS rules directly to an individual element using the style attribute. This method affects only the specific element where the style is applied.

Key Points About Inline Styles
  1. 1

    Use the style attribute inside an HTML tag to define CSS properties.

  2. 2

    Multiple CSS properties can be applied, separated by semicolons.

  3. 3

    Inline styles override external and internal CSS unless !important is used elsewhere.

Example Usage

In short: Inline styles are useful for quick, element-specific styling, but for maintainability and consistency, internal or external CSS is generally preferred.